﻿using MediatR;
using System.WXT.Domain;
using System.WXT.Infrstructre.Interface;
using System.WXT.WebAPI.Application.Command.WorkerCommand;

namespace System.WXT.WebAPI.Application.CommandHandlers.WorkerCommandHandlers
{
    public class WorkerUpdateCommandHandlers:IRequestHandler<WorkerUpdateCommand,int>
    {
        protected readonly IWorkerRepository workerRepository;

        public WorkerUpdateCommandHandlers(IWorkerRepository workerRepository)
        {
            this.workerRepository = workerRepository;
        }
        /// <summary>
        /// 工人修改
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<int> Handle(WorkerUpdateCommand request, CancellationToken cancellationToken)
        {
            var list = await workerRepository.Update(new Domain.Worker { workerId = request.workerId, workerNumbering = request.workerNumbering, workerName = request.workerName, workerPhone = request.workerPhone, workerSex = request.workerSex, workerTeam = request.workerTeam, workerDepartment = request.workerDepartment, workerState = request.workerState });
            return list;
        }
    }
}
